package com.ruoyi.teaching.service.impl;

import java.util.List;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.teaching.domain.vo.TeachingSchoolStatisticVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.teaching.mapper.TeachingSchoolMapper;
import com.ruoyi.teaching.domain.TeachingSchool;
import com.ruoyi.teaching.service.ITeachingSchoolService;
import com.ruoyi.common.core.text.Convert;

/**
 * 教务校区Service业务层处理
 *
 * @author William
 * @date 2022-10-10
 */
@Service
public class TeachingSchoolServiceImpl implements ITeachingSchoolService {
    @Autowired
    private TeachingSchoolMapper teachingSchoolMapper;

    /**
     * 查询教务校区
     *
     * @param schoolId 教务校区主键
     * @return 教务校区
     */
    @Override
    public TeachingSchool selectTeachingSchoolBySchoolId(Long schoolId) {
        return teachingSchoolMapper.selectTeachingSchoolBySchoolId(schoolId);
    }

    /**
     * 查询所有校区
     */

    public List<TeachingSchool> selectTeachingSchoolAll() {
        return teachingSchoolMapper.selectTeachingSchoolAll();
    }

    /**
     * 查询教务校区
     *
     * @param areaCode 区域ID
     * @return 教务校区
     */
    public List<TeachingSchool> selectTeachingSchoolByAreaCode(Long areaCode) {
        return teachingSchoolMapper.selectTeachingSchoolByAreaCode(areaCode);
    }

    /**
     * 查询教务校区列表
     *
     * @param teachingSchool 教务校区
     * @return 教务校区
     */
    @Override
    public List<TeachingSchool> selectTeachingSchoolList(TeachingSchool teachingSchool) {
        return teachingSchoolMapper.selectTeachingSchoolList(teachingSchool);
    }

    /**
     * 新增教务校区
     *
     * @param teachingSchool 教务校区
     * @return 结果
     */
    @Override
    public int insertTeachingSchool(TeachingSchool teachingSchool) {
        teachingSchool.setCreateTime(DateUtils.getNowDate());
        return teachingSchoolMapper.insertTeachingSchool(teachingSchool);
    }

    /**
     * 修改教务校区
     *
     * @param teachingSchool 教务校区
     * @return 结果
     */
    @Override
    public int updateTeachingSchool(TeachingSchool teachingSchool) {
        teachingSchool.setUpdateTime(DateUtils.getNowDate());
        return teachingSchoolMapper.updateTeachingSchool(teachingSchool);
    }

    /**
     * 批量删除教务校区
     *
     * @param schoolIds 需要删除的教务校区主键
     * @return 结果
     */
    @Override
    public int deleteTeachingSchoolBySchoolIds(String schoolIds) {
        return teachingSchoolMapper.deleteTeachingSchoolBySchoolIds(Convert.toStrArray(schoolIds));
    }

    /**
     * 删除教务校区信息
     *
     * @param schoolId 教务校区主键
     * @return 结果
     */
    @Override
    public int deleteTeachingSchoolBySchoolId(Long schoolId) {
        return teachingSchoolMapper.deleteTeachingSchoolBySchoolId(schoolId);
    }

    @Override
    public TeachingSchoolStatisticVO selectSchoolStatisticVoBySchoolId(Long schoolId) {
        return teachingSchoolMapper.selectSchoolStatisticVoBySchoolId(schoolId);
    }
}
